/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package br.ufc.quixada.adrs.comandos.supervisor;

import br.ufc.quixada.adrs.interfaces.Comando;
import br.ufc.quixada.adrs.service.AdministradorService;
import br.ufc.quixada.adrs.util.Msg;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 *
 * @author Franklin
 */
public class CmdExcluirAdministrador implements Comando {

    public String executa(HttpServletRequest request, HttpServletResponse response) {
        HttpSession session = request.getSession(true);
        AdministradorService administradorService = new AdministradorService();

        Long id = Long.parseLong(request.getParameter("id_administrador"));
               
        if (administradorService.deleteAdministrador(id)) {
            session.setAttribute("sucesso", Msg.SUCCESSFULLY_DELETED);
        } else {
            session.setAttribute("erro", Msg.OPERATIONAL_ERROR_DELETING_ADMINISTRADOR);
        }

        return "/ServletCentral?comando=CmdListarAdministradores";
    }
}